package com.hyts.fsm;

import java.lang.ref.WeakReference;

/**
 * Created by lmy on 2015/8/11.
 */
public class Row<Now, Event, Next> {

    private WeakReference<Now> mNowState;
    private Class<Event> mEvent;
    private WeakReference<Next> mNextState;

    public Row(Now nowState, Class<Event> t, Next nextState) {
        mNowState = new WeakReference<Now>(nowState);
        mNextState = new WeakReference<Next>(nextState);
        mEvent = t;
    }

    public <N, E> boolean isMatch(N nowState, E event) {

        if (mNowState.get() != nowState) {
            return false;
        }

        if ((event.equals(mEvent))) {
            //DebugLogHelper.InfoPrint("isMatch event is match...");
            return true;
        }

        return false;
    }

    public WeakReference<Next> getNextState() {
        return mNextState;
    }
}

